import 'package:flutter/material.dart';
import '../demo/ui_demo.dart';
import '../local/pages/context_header.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        centerTitle: true,
        elevation: 0,
        actions: <Widget>[
          IconSource("MaterialPageRoute","08"),
        ],
      ),
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            FlatButton(
              child: Text("HOME"),
              onPressed: (){
                debugPrint("home pressed");
                Navigator.of(context).push(MaterialPageRoute(
                  builder: (BuildContext context)=>SecondPage("HOME",Icon(Icons.home,size: 128,))
                ));
              },
            ),
            FlatButton(
              child: Text("ABOUT"),
              onPressed: (){
                debugPrint("about pressed");
//                Navigator.of(context).push(MaterialPageRoute(
//                    builder: (BuildContext context)=>SecondPage("ABOUT",Icon(Icons.poll,size: 128,))
//                ));
              App.navigateTo(context, "/about");
              },
            )
          ],
        ),
      ),
    );
  }
}

class SecondPage extends StatelessWidget{
  final String title;
  final Icon icon;
  const SecondPage(this.title,this.icon);
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        centerTitle: true,
        elevation: 0,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            this.icon,
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.arrow_back),
        onPressed: (){
          App.pop(context);
        },
      ),
    );
  }
}
